// GetValueFromString.h: interface for the GetValueFromString class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_GETVALUEFROMSTRING_H__9B549347_44E6_4CD4_B95C_2A178FEF83C2__INCLUDED_)
#define AFX_GETVALUEFROMSTRING_H__9B549347_44E6_4CD4_B95C_2A178FEF83C2__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <sstream>

class ValueConverter
{
protected:
	ValueConverter() {}
	virtual ~ValueConverter();

public:
	template <class InType, class OutType> static void ConvertValue(const InType& inValue, OutType& outValue)
	{
		std::stringstream ss;
		ss << inValue; // first insert value to stream
		ss >> outValue; // write value to result
	}

	template <class OutType> static void StringTokenizer(const char* pStr, const char* pSeps, std::vector<OutType>& vecTokens)
	{
		ASSERT(strlen(pStr) < 1023);
		vecTokens.clear();
		char SymBuf[1024] = {0};
		strcpy(SymBuf, pStr);
		char *pToken = strtok(SymBuf, pSeps);
		while(pToken != NULL)
		{
			OutType value;
			ConvertValue(pToken, value);
			vecTokens.push_back(value);
			// Get next token:
			pToken = strtok(NULL, pSeps);
		}
	}
};

#endif // !defined(AFX_GETVALUEFROMSTRING_H__9B549347_44E6_4CD4_B95C_2A178FEF83C2__INCLUDED_)
